﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Collections;

public partial class CMS_Admin_CheckList : System.Web.UI.Page
{
    Usas.Common.Cms.Role ro = new Usas.Common.Cms.Role();
    Usas.Common.Cms.CurrentInfo cinfo = new Usas.Common.Cms.CurrentInfo();
    Usas.BLL.Cms.cmsArticle ar = new Usas.BLL.Cms.cmsArticle();
    Usas.BLL.Cms.AspPager ap = new Usas.BLL.Cms.AspPager();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                if (Request["page"] == null)
                {
                    Bind(1, Request["c"].ToString());
                }
                else
                {
                    Bind(Convert.ToInt32(Request["page"]), Request["c"].ToString());
                }
            }
            catch
            {
            }
        }
    }

    private void Bind(int page, string c)
    {
        string name = "";
        if (Request["name"] != null)
        {
            name = " and ArtTopic like '%" + Server.UrlDecode(Request["name"]) + "%' ";
            txttopic.Text = Server.UrlDecode(Request["name"]);
        }
        DataTable dt = null;
        string usasdb = System.Configuration.ConfigurationManager.AppSettings["ConnectionStringUsas"].ToString();
        int count = 0;
        string where = "";
        if (c == "a")
        {
            where = " IsCheck ='1' and CmsBorder.Del=0 and CmsType.Del=0 and (IsVersion='0' or IsVersion is null) and PublishStatus=2 " + name;
        }
        else
        {
            where = " IsCheck ='1' and CmsBorder.Del=0 and CmsType.Del=0 and CheckPerson=" + cinfo.GetEmpId() + " and (IsVersion='0' or IsVersion is null) and PublishStatus=2 " + name;
        }
        string table = " cmsArticle inner join CmsBorder on (CmsBorder.BorderId=cmsArticle.BorderId) inner join CmsType on (CmsType.TypeId=cmsArticle.TypeId) ";
        string PK = "ArtId";
        string cols = "cmsArticle.ArtId,cmsArticle.ArtTopic,CmsBorder.BorderName,CmsType.TypeName";
        string by = "ModfiyTime";

        dt = ap.ShowListDesc(table, where, PK, 12, page, cols);

        if (dt != null)
        {
            if (dt.Rows.Count > 0)
            {
                RptChatList.DataSource = dt;
                RptChatList.DataBind();

                apg.CurrentPageIndex = page;
                apg.PageSize = 12;
                apg.RecordCount = ap.ShowListCount(table, where, PK);



            }
            else
            {
                DivContent.InnerHtml = "<div style='text-algin:center'>没有审核内容</div>";
            }
        }
        else
        {
            DivContent.InnerHtml = "<div style='text-algin:center'>没有审核内容</div>";
        }

    }

    protected void RptChatList_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            DataRowView drv = (DataRowView)e.Item.DataItem;

            HyperLink hygoto = (HyperLink)e.Item.FindControl("hygoto");
            hygoto.Text = "<img src=\"../images/edit.gif\" border=\"0\" title=\"审核\" /> 进入审核";
            hygoto.NavigateUrl = "javascript:void(0)";
            hygoto.Attributes.Add("style", " text-decoration:none;");
            hygoto.Attributes.Add("onclick", "openwin('" + drv["ArtId"].ToString() + "','" + ro.GetMd5Str32(drv["ArtId"].ToString() + "check") + "')");


            CMS_Control_RouterBar rb = (CMS_Control_RouterBar)e.Item.FindControl("RouterBar1");
            rb.IntiBarNoHTML(CMS_Control_RouterBar.ShowMode.Article, Convert.ToInt32(drv["ArtId"].ToString()), new ArrayList());
            //ldel.CommandName = "Del";
            //ldel.CommandArgument = drv["ReviewId"].ToString();
            //if (ro.GetMd5Str(Request["id"].ToString() + "checkTrue") == Request["check"].ToString())
            //{
            //    ldel.Visible = true;
            //}
            //else
            //{
            //    if (drv["Reviewer"].ToString() == cinfo.GetEmpId())
            //    {
            //        ldel.Visible = true;
            //    }
            //    else
            //    {
            //        ldel.Visible = false;
            //    }
            //}
        }
    }

    protected void RptChatList_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "Del")
        {
            //rv.Delete(Convert.ToInt32(e.CommandArgument));
            //ClientScript.RegisterStartupScript(GetType(), "Msg", "alert('执行成功！');location.href='" + Request.Url.ToString() + "'", true);

        }
    }
    protected void Save_Click(object sender, EventArgs e)
    {
        Response.Redirect(Request.Url.ToString());
    }

    protected void Search_Click(object sender, EventArgs e)
    {

        if (Request["page"] != null)
        {
            if (txttopic.Text.Trim().Length <= 0)
            {
                Response.Redirect("CheckList.aspx?c=" + Request["c"].ToString() + "page=" + Request["page"].ToString());
            }
            else
            {
                Response.Redirect("CheckList.aspx?c=" + Request["c"].ToString() + "page=" + Request["page"].ToString() + "&name=" + Server.UrlEncode(txttopic.Text.Trim()));
            }
        }
        else
        {
            if (txttopic.Text.Trim().Length <= 0)
            {
                Response.Redirect("CheckList.aspx?c=" + Request["c"].ToString());
            }
            else
            {
                Response.Redirect("CheckList.aspx?c=" + Request["c"].ToString() + "&name=" + Server.UrlEncode(txttopic.Text.Trim()));
            }
        }

    }


}
